<!DOCTYPE html>
<html>
<head>
<title>慧听智能语音庭审系统-登录</title>
<link href="@{'/public/stylesheets/login/style.css'}" rel="stylesheet" type="text/css">
<style type="text/css">
	.loginuser{
		background-size:100% 100%;
	}
	.loginpwd{
		background-size:100% 100%;
	}
</style>
</head>
<body>
<div id="mainBody">
    <div id="cloud1" class="cloud"></div>
    <div id="cloud2" class="cloud"></div>
</div>
<div class="loginbody" style="width: 100%; height: 100%; background-image: url(&quot;@{'/public/images/login_bg.png'}&quot;); background-size: 100% 100%; background-repeat: no-repeat;">
	<span id="systemlogo" class="systemlogo" style="width:100%; height:71px; margin-top:10%;"></span>
	<div class="loginbox" style="top:50%;left:50%;margin-top:-116px;margin-left:-300px;position:fixed;">
	   <div style="top: -180px;left: 50%;margin-left: -230px;position: absolute;z-index: 1;">
	      <img id="loginLogo" src="@{'/public/images/login_logo.png'}">
	   </div>
	   <div style="margin-left:110px"> 
			   #{authenticityToken /}
			   <ul>
				   <li><input id="userName" name="username" type="text" class="loginuser" value="username" onfocus="clearUserContent()" onblur="onUserBlur()"></li>
				   <li>
					   	<!-- <input id="password" name="password" type="password" class="loginpwd" value="password" onblur="onPwdBlur()" style="display: none;" onfocus="clearPwdContent()">
					    <input class="loginpwd" type="text" id="passwordShow" name="passwordShow" value="password" onfocus="showReal()" style="display: block;"> -->
					    <input id="password" name="password" type="password" class="loginpwd" value="password"  onblur ="showFake()" style="display:none;">
			    		<input class="loginpwd" type="text" id="passwordShow"  name="passwordShow" value="password" onfocus="showReal()">
				   </li>
				   <li style="padding-left:30px">
				   	<button class="loginbtn" id="SubButton">登录</button>
				    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				    <input name="" id="buttonid" type="button" class="loginbtn" value="重置">
				   </li>
			   </ul>
		</div>
	</div>
</div>
<!-- <div class="loginbm">Copyright ©2017 北京捷通华声科技股份有限公司&nbsp;&nbsp;&nbsp;灵云：www.hcicloud.com</div> -->
   <!-- 模态框（Modal） -->
<div class="modal fade" id="errorMsg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog" align="center">
      <div class="modal-content" style="background-color: #f6f6f6">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                  ×
            </button>
           <!--  <h4 class="modal-title" id="myModalLabel" style="font-size:22px;color:rgb(115,115,115)">
              	登录失败
            </h4> -->
         </div>
         <div class="modal-body" id="modal-body" align="center" style="height:70px; pading-bottom:15px !important">
         
         </div>
       <!--  <div class="modal-footer">
            <button type="button" class="btn btn-warning" style="background-color:rgb(98,151,205);width:75px;" data-dismiss="modal">关闭</button>
         </div> -->
      </div>
	</div>/.modal
</div>
</body>
<script type="text/javascript" src="@{'/public/javascripts/layout/jquery-1.11.1.min.js'}"></script>
<script type="text/javascript" src="@{'/public/javascripts/layout/jquery.cookie.js'}"></script>
<script type="text/javascript" src="@{'/public/javascripts/layout/bootstrap.js'}"></script>
<script type="text/javascript" src="@{'/public/javascripts/layout/cloud.js'}"></script>
<script type="text/javascript">
	var userNameMaxLength = 50;
	var passwordMinLength = 4;
	var passwordMaxLength = 50;
	$(function() {
		document.getElementById("buttonid").onclick=function(){reset();};
		initSysLogo();
		if(navigator.userAgent.indexOf("MSIE 8.0")>0) {  
			$(".loginbody").css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='@{'/public/images/login_bg.png'}', sizingMethod='scale')");
	    }else {
	    	$(".loginbody").css("background-size","100% 100%");
	    }   
		$(".back_center").addClass("active");
		if (!((navigator.userAgent.indexOf('MSIE') >= 0)&& (navigator.userAgent.indexOf('Opera') < 0))){
			$("#passwordShow").css("display","none");
			$("#password").css("display","block");
			$("#password").attr("type","text");
			$("#password").val("password");
			$("#password").attr("onfocus","clearPwdContent()");
			$("#password").attr("onblur","onPwdBlur()");
		}else{
			$("#password").val("");
		}
		
		/* $("#errorMsg").on('show.bs.modal', function (e) {  
		    $(this).find('.modal-dialog').css({  
		        'margin-top': function () {  
		            var modalHeight = $('#errorMsg').find('.modal-dialog').height();  
		            return ($(window).height() / 2 - (modalHeight / 2)-200);  
		        }  
		    });      
		});   */
 		$(window).resize(function() {
			var fullHeight = $(document).height();
			if(fullHeight<650){
				$(".systemlogo").hide();
			}else{
				$(".systemlogo").show();
			}
		}); 
 		var msg="";
		if(msg!=null&&msg!=""){
			showError(msg);
		}
		compatibility();
		
	}); 
	function compatibility(){
		var fullHeight = document.documentElement.clientHeight;
		if(fullHeight<585){
			$("#systemlogo").css("margin-top","0px");
		}
	}
	function reSetPwd(){
		$("#userName").val("username");
		window.location.href=window.location.href;
		location.reload();
	}
	function loginCheck(){
		var name = $.trim($("#userName").val());
		var userPassword =$.trim($("#password").val());
		if(name == "username"){
//			showError("用户名为空！");
			return "用户名为空！";
		}
		if (userPassword == "password"||userPassword == ""){
//			showError("密码为空！");
			return "密码为空！";
		}
		/* if (userPassword.length<6){
			showError("密码长度不能小于6！");
			return false;
		} */
		return "";
	}
	
	function showError(msg){
		$("#modal-body").html("<span style='padding-top:20px;font-size:18px;color:rgb(115,115,115)'>"+msg+"</span>");
		$("#errorMsg").modal('show'); 
	}
	
	function clearContent(){
		$("#userName").val("username");
		$("#password").val("");
		showFake();
	}
	$(function() {
		if (window.top!=null && window.top.document.URL!=document.URL){ 
			 window.top.location= document.URL; 
		 } 
		$("body").keydown(function(e){ 
			var curKey = e.which;
			if(curKey == 13){ 
				$("#SubButton").click();
				return false; 
			} 
		});
	})
	var $Path='${ctxPath}';
	$("#SubButton").click(function(){
			var check=loginCheck();
			if(check!=""&&check!=null){
				showError(check);
				return;
			}
			var data={
					operatorid:$("#userName").val(),
					password:$("#password").val(),
					codeId:'${codeId}',
					authenticityToken:$("input[name='authenticityToken']").val()
			}
			$("#SubButton").attr("disable",false);
			$.ajax({
				type:"post",
				data:data,
				url:$Path+"/admin/dologin",
				success:function(data){
					if(data.code==200){
						$("#SubButton").attr("disable",true);
						$.cookie('username', data.msg, {expires:30});
						window.location.href=$Path+"/admin/index";
					}else{
						$("#SubButton").attr("disable",true);
						showError(data.msg);
					}
				},
				error:function(){
					$("#SubButton").attr("disable",true);
					showError("服务器开小差了~");
				}
			})
		})
	function initSysLogo(){
		if(true){
			$("#loginLogo").attr("src","@{'/public/images/login_logo.png'}");
		}else{
/* 			$("#loginLogo").attr("src","./themes/images/login_logokf.png");
 */		}
	}
	function reset(){
		$("#userName").val("username");
		$("#password").val("");
		$("#password").css("display","none");
		$("#passwordShow").css("display","block");
	}
	function clearUserContent() {
		if (document.getElementById("userName").value == "username") {
			document.getElementById("userName").value = "";
		}
	}
	function onUserBlur() {
		if (document.getElementById("userName").value == "") {
			document.getElementById("userName").value = "username";
		}
	}
	function showReal() {
		tx = document.getElementById("passwordShow"); 
		if (tx.value != "password") 
			return; 
		tx.style.display = "none"; 
		pwd = document.getElementById("password"); 
		pwd.style.display = "block"; 
		pwd.value="";
		pwd.focus(); 
	}

	function showFake() {
		pwd = document.getElementById("password"); 
		if (pwd.value != "") 
			return; 
		pwd.style.display = "none"; 
		tx = document.getElementById("passwordShow"); 
		tx.style.display = "block"; 
		tx.value = "password"; 
	}
	
	function clearPwdContent() {
		if (document.getElementById("password").value == "password") {
			document.getElementById("password").value = "";
		}

		document.getElementById("password").type = "password";
	}

	function onPwdBlur() {
		if (!+[ 1, ]) {
		} else {
			if (document.getElementById("password").value == "") {
				document.getElementById("password").value = "password";
				document.getElementById("password").type = "text";
			}
		}
	}
	
</script>
</html>